<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
        $this->display();
    }

    public function updateTable($name ='',$pk ='',$value)
    {
        $Model = M();
        $sql = "ALTER TABLE `".$name."` COMMENT='".$value."' ;";
        $Model->execute($sql);
        $this->success();
    }

    public function insertItem()
    {
        $f = I('ename');
        $p = $_POST;
        foreach ($p as $key => $v) {
            if (!$v) {
                if (!$v) $this->error('请填写完整参数');
                return;
            }
        }
        if (!$f) $this->error('请填写完整参数');
        F(C('ITEM_DIR').$f,$p);
        $this->success('新建项目成功');
    }

    public function editItem($f='')
    {
        $vo = F(C('ITEM_DIR').$f);
        $this->assign('vo', $vo);
        $this->display();
    }


    public function updateItem()
    {
        $f = I('f');
        $p = $_POST;
        foreach ($p as $key => $v) {
            if (!$v) {
                if (!$v) $this->error('请填写完整参数');
                return;
            }
        }
        if (!$f) $this->error('请填写完整参数');
        F(C('ITEM_DIR').$f,$p);
        $this->success('修改项目成功');
    }
}
